#include "WiredQuadrilateral.h"

WiredQuadrilateral::WiredQuadrilateral()
{
}

WiredQuadrilateral::WiredQuadrilateral(QList<QPoint*> vertexs)
{
    m_vertexs = vertexs;
}

WiredQuadrilateral::WiredQuadrilateral(QList<QPoint*> vertexs,QList<QColor*> colors)
{
    m_vertexs = vertexs;
    m_colors = colors;
}

WiredQuadrilateral::WiredQuadrilateral(QPoint* p1, QPoint* p2, QPoint* p3,QPoint* p4)
{
    m_vertexs.clear();
    m_vertexs.append(p1);
    m_vertexs.append(p2);
    m_vertexs.append(p3);
    m_vertexs.append(p4);
}

void WiredQuadrilateral::draw(QPainter* painter)
{
    QPoint* p1 = m_vertexs.at(0);
    QPoint* p2 = m_vertexs.at(1);
    QPoint* p3 = m_vertexs.at(2);
    QPoint* p4 = m_vertexs.at(3);

    Line* l1 = new Line(p1,p2);
    l1->setColors(colors().mid(4,1) << colors().mid(4,1));
    l1->draw(painter);

    Line* l2 = new Line(p2,p3);
    l2->setColors(colors().mid(4,1) << colors().mid(4,1));
    l2->draw(painter);

    Line* l3 = new Line(p3,p4);
    l3->setColors(colors().mid(4,1) << colors().mid(4,1));
    l3->draw(painter);

    Line* l4 = new Line(p4,p1);
    l4->setColors(colors().mid(4,1) << colors().mid(4,1));
    l4->draw(painter);
}
